package com.example.java8.streamdemo.streamdemo.DistinctClassDemo;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import sun.java2d.pipe.SpanIterator;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @Author by KoVaVo
 * @Date 2021-08-26 21:26
 * @Desc: 对于实体类的去重=》根据实体中的每个字符去比较
 */
public class DistinctClassDemo {
    public static void main(String[] args) throws JsonProcessingException {
        ObjectMapper objectMapper = new ObjectMapper();
        List<student> students = stuList.getStuList();
        System.out.println("去重前。。。");
        String s = objectMapper.writeValueAsString(students);
        System.out.println(s);
        System.out.println("去重后。。。");
        List<student> collect = students.stream().distinct().collect(Collectors.toList());
        String s1 = objectMapper.writeValueAsString(collect);
        System.out.println(s1);
    }
}
